package cn.itcast.mapper;

import cn.itcast.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ICategoryMapper {
    //查找全部
    @Select(" SELECT * FROM category order by sort")
    List<Category> findAll();
    //插入一条数据
    @Insert("insert into category values (null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser}" +
            ",#{updateUser})")
    void  save(Category category);

    //删除数据
    @Delete("delete from category where id=#{id}")
    void delete(Long id);

    @Update("UPDATE category SET `TYPE` = #{type},`name`=#{name},sort=#{sort}" +
            ",update_time=#{updateTime},update_user=#{updateUser} where id =#{id} ")
    void update(Category category);

    List<Category> list(Integer type);

    @Select("select * from category where id=#{id}")
    Category findById(Long id);
}
